home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS26.ADF
/
HexDump
/
HexDump1.mod
< prev
next >
Wrap
Text File
|
1989-01-26
|
4KB
|
98 lines
MODULE HexMemoryDump;
(*$S-,$T-,$A+*)
(* This program dumps the hex listing of memory. *)
FROM InOut IMPORT WriteString, WriteLn;
FROM SYSTEM IMPORT LONGWORD, ADDRESS, TSIZE;
FROM AMIGAX IMPORT CLinePtr, CLineLen;
FROM Hex IMPORT ConvertHexStringToCardinal, HexDump, WriteHex,
WriteChar, str80, OutType, CharType, LeftByte,
RightByte, CharOut, CharIndex;
FROM HexParser IMPORT LineFeed, IsAlpha, IsDelimiter, IsDigit;
VAR
StartingLocation : str80; (* String for starting location *)
EndingLocation : str80; (* String for ending location *)
Out : OutType; (* Output array *)
Start : LONGCARD; (* Value of starting address *)
End : LONGCARD; (* Value of ending address *)
Delta : LONGCARD; (* Number of bytes to output times 2 *)
StartDump : LONGWORD; (* Where to start dump *)
StartDumpPtr : ADDRESS; (* Address of where to start dump *)
FirstParameter : BOOLEAN; (* First parameter flag *)
SecondParameter : BOOLEAN; (* Second parameter flag *)
x : LONGCARD; (* Dummy counter *)
y,z : CARDINAL; (* Counter because array can not use
LONGCARD index *)
BEGIN
(* Initialize parameters. *)
Start := 0;
CharIndex := 1;
FirstParameter := FALSE;
SecondParameter := FALSE;
(* Read input line and generate an ASCII string. *)
FOR x := 1 TO CLineLen DIV 2 DO
WriteHex(CARDINAL(CLinePtr^),LeftByte,RightByte,Out);
WriteChar(CharOut,CharIndex,LeftByte,RightByte);
INC(CLinePtr,TSIZE(CARDINAL));
END; (* FOR *)
(* Initialize array indices. *)
y := 1;
z := 1;
FOR x := 1 TO CLineLen DO
(* Perform parser on input string. *)
IF ((NOT IsDelimiter(CharOut,z)) AND (NOT LineFeed(CharOut,z))) THEN
IF (NOT IsDigit(CharOut,z)) THEN
IF (NOT IsAlpha(CharOut,z)) THEN
(* Unknown character! *)
WriteString('Unknown character!');WriteLn;
ELSE
(* If alpha character determine if first parameter or second
parameter and put in proper string. *)
IF (NOT FirstParameter) THEN
StartingLocation[y-1] := CAP(CharOut[z]);
ELSE
EndingLocation[y-1] := CAP(CharOut[z]);
END;
END;
ELSE
(* If digit character determine if first parameter or second
parameter and put in proper string. *)
IF (NOT FirstParameter) THEN
StartingLocation[y-1] := CAP(CharOut[z]);
ELSE
EndingLocation[y-1] := CAP(CharOut[z]);
END;
END;
ELSE
(* If delimiter or line feed then calculate the start or end
value. *)
IF (NOT FirstParameter) THEN
FirstParameter := TRUE;
ConvertHexStringToCardinal(Start,StartingLocation);
(* Initialize array parameter for second parameter string. *)
y := 0;
ELSE
SecondParameter := TRUE;
ConvertHexStringToCardinal(End,EndingLocation);
END;
END;
(* Increment array indices. *)
y := y + 1;
z := z + 1;
END; (* FOR *)
(* Calculate the number of bytes to output. *)
Delta := (End - Start) DIV 2;
(* Initialize the character index. *)
CharIndex := 1;
(* Calculate starting address. This is critical to proper operation. *)
StartDump := LONGWORD(Start);
StartDumpPtr := ADDRESS(StartDump);
(* Dump memory and ASCII equivalent. *)
HexDump(StartDumpPtr,Delta,Out);
END HexMemoryDump.